package cn.tedu.mybatisexercise1.mapper;

import cn.tedu.mybatisexercise1.pojo.order;
import cn.tedu.mybatisexercise1.pojo.orderVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {
    @Insert("INSERT INTO orders VALUES (NULL,#{state},#{amount},#{created})")
    void insert(order o);

    @Select("SELECT * FROM orders")
    List<order>selectAll();

    @Select("SELECT * FROM orders WHERE id=#{id}")
    order selectOne(int id);

    @Update("UPDATE orders SET state=#{state},amount=#{amount},created=#{created} WHERE id=#{id}")
    void updateOne(order o);

    @Delete("DELETE FROM orders WHERE id=#{id}")
    void deleteById(int id);

    @Select("SELECT COUNT(*) FROM orders")
    int selectCount();

    @Select("SELECT state ,amount FROM orders")
    List<orderVO>selectTwo();
}
